package com.bank.dao;

import java.sql.*;

public class AdminDAO {
    // 修改表名为 "admin"
    private static final String TABLE_NAME = "admin";

    /**
     * 管理员登录验证
     */
    public static boolean login(String adminID, String password) throws SQLException {
        String sql = "SELECT * FROM " + TABLE_NAME + " WHERE adminID = ? AND password = ?";
        System.out.println("执行SQL: " + sql);

        try (Connection conn = DBUtil.getConnection();
             PreparedStatement ps = conn.prepareStatement(sql)) {

            ps.setString(1, adminID);
            ps.setString(2, password);

            try (ResultSet rs = ps.executeQuery()) {
                return rs.next();
            }
        } catch (SQLException e) {
            System.err.println("管理员登录查询失败: " + e.getMessage());
            throw e;
        }
    }
}